package com.loongtech.bi.manager.game;

import com.loongtech.bi.action.PageHelper;
import com.loongtech.bi.action.game.TaskGameAction;
import com.loongtech.bi.entity.game.*;
import com.loongtech.bi.support.chart.ChartData1;
import com.loongtech.bi.support.chart.ChartFlow;
import com.loongtech.bi.support.chart.ChartSelect;
import com.loongtech.core.jpa.manager.ManagerQueryCacheBase;
import com.loongtech.core.util.Time;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;
import java.util.Map.Entry;

/**
 * 任务分析-manager
 *
 */
@Service
public class TaskGameManager extends ManagerQueryCacheBase<Object> {
    private static final long serialVersionUID = 1L;

    @Autowired
    ActiveRoleTaskStatusRoleNumManager activeRoleTaskStatusRoleNumManager;
    @Autowired
    NewRoleTaskStatusRoleNumManager newRoleTaskStatusRoleNumManager;
    @Autowired
    ActiveRoleTaskStatusTimesManager activeRoleTaskStatusTimesManager;
    @Autowired
    NewRoleTaskStatusTimesManager newRoleTaskStatusTimesManager;
    @Autowired
    private ActiveUser1LevelDistributeManager activeUser1LevelDistributeManager;
    @Autowired
    private NewUser1LevelDistributeManager newUser1LevelDistributeManager;
    @Autowired
    private ActiveRoleTaskStayManager activeRoleTaskStayManager;
    @Autowired
    private NewRoleSecondLossTaskStayManager newRoleSecondLossTaskStayManager;

    public List<TaskActiveOrNewUserStatus> getTaskActiveUserStatus(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer, List<Integer> queryTaskName, Map<String, Map<String, Integer>> levelNumTemp) {
       /* if (TaskGameAction.taskOpenLevel == null || TaskGameAction.taskOpenLevel.size() <= 1) {  // 开启等级没配，直接返回
            System.out.println("任务开启等级没配！");
            return null;
        }*/

        List<EntityActiveRoleTaskStatusRoleNum> activeRoleTaskStatusRoleNum = activeRoleTaskStatusRoleNumManager.getActiveRoleTaskStatusRoleNum(dateStart, dateEnd, queryPlatform, queryChannel, queryServer, queryTaskName);
        if (activeRoleTaskStatusRoleNum == null || activeRoleTaskStatusRoleNum.size() <= 0) {
            System.out.println("active_role_task_status_rolenum为空");
            return null;
        }

        List<EntityActiveRoleTaskStatusTimes> activeRoleTaskStatusTimes = activeRoleTaskStatusTimesManager.getActiveRoleTaskStatusTimes(dateStart, dateEnd, queryPlatform, queryChannel, queryServer, queryTaskName);
        if (activeRoleTaskStatusTimes == null || activeRoleTaskStatusTimes.size() <= 0) {
            System.out.println("active_role_task_status_times为空");
            return null;
        }

        Map<String, Map<String, Map<String, TaskActiveOrNewUserStatus>>> resultMap = new HashMap<>();  // 时间={任务ID={任务状态=TaskActiveOrNewUserStatus}}

        // 求出activeRoleTaskStatusRoleNum中包含的各个指标
        for (EntityActiveRoleTaskStatusRoleNum e : activeRoleTaskStatusRoleNum) {
            String dateStr = Time.getDateStr(e.getDay());
            String taskId = e.getTaskid() + "";
            String status = e.getStatus() + "";

            /*if (!TaskGameAction.taskOpenLevel.containsKey(taskId)) {  // 没配开启等级
                System.out.println("没有配开启等级：任务ID=" + taskId);
                continue;
            }*/

            Map<String, Map<String, TaskActiveOrNewUserStatus>> tmp1 = resultMap.get(dateStr);
            if (tmp1 == null) {
                tmp1 = new HashMap<>();
                resultMap.put(dateStr, tmp1);
            }
            Map<String, TaskActiveOrNewUserStatus> tmp2 = tmp1.get(taskId);
            if (tmp2 == null) {
                tmp2 = new HashMap<>();
                tmp1.put(taskId, tmp2);
            }
            TaskActiveOrNewUserStatus tmp3 = new TaskActiveOrNewUserStatus();
            tmp3.setDateStr(Time.getDateStr(e.getDay())); // 日期
            tmp3.setTaskId(taskId); // 任务ID
            tmp3.setTaskName(TaskGameAction.taskName.get(taskId) == null ? taskId : TaskGameAction.taskName.get(taskId)); // 任务名称
            tmp3.setTaskType(TaskGameAction.taskType.get(taskId) == null ? taskId : TaskGameAction.taskType.get(taskId)); // 任务类型
            tmp3.setTaskStatus(status);
            // tmp3.setOpenLevel(Integer.parseInt(TaskGameAction.taskOpenLevel.get(taskId))); // 开启等级
            tmp3.setPlayUserNum(e.getRolenum()); // 参与角色数

            tmp2.put(status, tmp3);
        }

        // 求出activeRoleTaskStatusTimes中包含的各个指标
        for (EntityActiveRoleTaskStatusTimes e : activeRoleTaskStatusTimes) {
            String dateStr = Time.getDateStr(e.getDay());
            String taskId = e.getTaskid() + "";
            String status = e.getStatus() + "";

            Map<String, Map<String, TaskActiveOrNewUserStatus>> tmp0 = resultMap.get(dateStr);
            if (tmp0 == null) {
                continue;
            }
            Map<String, TaskActiveOrNewUserStatus> tmp1 = tmp0.get(taskId);
            if (tmp1 == null) {
                continue;
            }
            TaskActiveOrNewUserStatus tmp2 = tmp1.get(status);
            if (tmp2 == null) {
                continue;
            }
            tmp2.setAvgTime(e.getSumpasstime());  // 平均时间
            tmp2.setPlayTimes(e.getTimes());  // 总次数
        }

        Map<String, TaskActiveOrNewUserStatus> resultMap2 = new LinkedHashMap<>();
        // 整理数据
        for (Entry<String, Map<String, Map<String, TaskActiveOrNewUserStatus>>> entry : resultMap.entrySet()) {
            String dateStr = entry.getKey();
            Map<String, Map<String, TaskActiveOrNewUserStatus>> value = entry.getValue();
            for (Entry<String, Map<String, TaskActiveOrNewUserStatus>> entry1 : value.entrySet()) {
                String taskId = entry1.getKey();
                Map<String, TaskActiveOrNewUserStatus> value1 = entry1.getValue();
                for (Entry<String, TaskActiveOrNewUserStatus> entry2 : sortMapByKey(value1).entrySet()) {
                    String taskStatus = entry2.getKey();
                    TaskActiveOrNewUserStatus v = entry2.getValue();

                    TaskActiveOrNewUserStatus t = resultMap2.get(dateStr + "-" + taskId);
                    if (t == null) {
                        t = new TaskActiveOrNewUserStatus();
                        t.setDateStr(dateStr);
                        t.setTaskId(v.getTaskId());
                        t.setTaskName(v.getTaskName());
                        t.setTaskType(v.getTaskType());
                        t.setOpenLevel(v.getOpenLevel());
                        // t.setOkUserNum(okusernum);

                        resultMap2.put(dateStr + "-" + taskId, t);
                    }
                    if (taskStatus.equals(TaskGameAction.task_join_status)) {  // 参与任务
                        t.setPlayUserNum(v.getPlayUserNum());
                        t.setPlayRadio(t.getOkUserNum() == 0 ? 0 : PageHelper.floatKeepTwoNumber(t.getPlayUserNum() * 1.0 / t.getOkUserNum()));
                        t.setPlayTimes(v.getPlayTimes());
                        t.setAvgPlayTimes(t.getPlayTimes() == 0 ? 0 : (int) Math.round(t.getPlayTimes() * 1.0 / t.getPlayUserNum()));
                        if (t.getPlayRadio() > 1) {
                            t.setPlayRadio(1);
                        }
                    } else if (taskStatus.equals(TaskGameAction.task_pass_status)) {  // 完成任务
                        t.setOkPlayTimes(v.getPlayTimes());
                        t.setOkRadio(t.getPlayTimes() == 0 ? 0 : PageHelper.floatKeepTwoNumber(t.getOkPlayTimes() * 1.0 / t.getPlayTimes()));
                        t.setAvgTime(t.getPlayTimes() == 0 ? 0 : PageHelper.floatKeepTwoNumber(v.getAvgTime() / 60.0 / t.getOkPlayTimes()));
                        if (t.getOkRadio() > 1) {
                            t.setOkRadio(1);
                        }
                    }
                }
            }
        }

        ArrayList<TaskGameManager.TaskActiveOrNewUserStatus> result = new ArrayList<>(resultMap2.values());
        Collections.sort(result, new TaskGameManager.TaskActiveOrNewUserStatus().comparatorDate);

        return result;
    }

    public List<TaskActiveOrNewUserStatus> getTaskNewUserStatus(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer, List<Integer> queryTaskName, Map<String, Map<String, Integer>> levelNumTemp) {
        /*if (TaskGameAction.taskOpenLevel == null || TaskGameAction.taskOpenLevel.size() <= 1) {  // 开启等级没配，直接返回
            System.out.println("任务开启等级没配！");
            return null;
        }*/

        List<EntityNewRoleTaskStatusRoleNum> newRoleTaskStatusRoleNum = newRoleTaskStatusRoleNumManager.getNewRoleTaskStatusRoleNum(dateStart, dateEnd, queryPlatform, queryChannel, queryServer, queryTaskName);
        if (newRoleTaskStatusRoleNum == null || newRoleTaskStatusRoleNum.size() <= 0) {
            System.out.println("new_role_task_status_rolenum为空");
            return null;
        }

        List<EntityNewRoleTaskStatusTimes> newRoleTaskStatusTimes = newRoleTaskStatusTimesManager.getNewRoleTaskStatusTimes(dateStart, dateEnd, queryPlatform, queryChannel, queryServer, queryTaskName);
        if (newRoleTaskStatusTimes == null || newRoleTaskStatusTimes.size() <= 0) {
            System.out.println("new_role_task_status_times为空");
            return null;
        }

        Map<String, Map<String, Map<String, TaskActiveOrNewUserStatus>>> resultMap = new HashMap<>();  // 时间={任务ID={任务状态=TaskActiveOrNewUserStatus}}

        // 求出newRoleTaskStatusRoleNum中包含的各个指标
        for (EntityNewRoleTaskStatusRoleNum e : newRoleTaskStatusRoleNum) {
            String dateStr = Time.getDateStr(e.getDay());
            String taskId = e.getTaskid() + "";
            String status = e.getStatus() + "";

           /* if (!TaskGameAction.taskOpenLevel.containsKey(taskId)) {  // 没配开启等级
                System.out.println("没有配开启等级：任务ID=" + taskId);
                continue;
            }*/

            Map<String, Map<String, TaskActiveOrNewUserStatus>> tmp1 = resultMap.get(dateStr);
            if (tmp1 == null) {
                tmp1 = new HashMap<>();
                resultMap.put(dateStr, tmp1);
            }
            Map<String, TaskActiveOrNewUserStatus> tmp2 = tmp1.get(taskId);
            if (tmp2 == null) {
                tmp2 = new HashMap<>();
                tmp1.put(taskId, tmp2);
            }
            TaskActiveOrNewUserStatus tmp3 = new TaskActiveOrNewUserStatus();
            tmp3.setDateStr(Time.getDateStr(e.getDay())); // 日期
            tmp3.setTaskId(taskId); // 任务ID
            tmp3.setTaskName(TaskGameAction.taskName.get(taskId) == null ? taskId : TaskGameAction.taskName.get(taskId)); // 任务名称
            tmp3.setTaskType(TaskGameAction.taskType.get(taskId) == null ? taskId : TaskGameAction.taskType.get(taskId)); // 任务类型
            tmp3.setTaskStatus(status);
            // tmp3.setOpenLevel(Integer.parseInt(TaskGameAction.taskOpenLevel.get(taskId))); // 开启等级
            tmp3.setPlayUserNum(e.getRolenum()); // 参与角色数

            tmp2.put(status, tmp3);
        }

        // 求出newRoleTaskStatusTimes中包含的各个指标
        for (EntityNewRoleTaskStatusTimes e : newRoleTaskStatusTimes) {
            String dateStr = Time.getDateStr(e.getDay());
            String taskId = e.getTaskid() + "";
            String status = e.getStatus() + "";

            Map<String, Map<String, TaskActiveOrNewUserStatus>> tmp0 = resultMap.get(dateStr);
            if (tmp0 == null) {
                continue;
            }
            Map<String, TaskActiveOrNewUserStatus> tmp1 = tmp0.get(taskId);
            if (tmp1 == null) {
                continue;
            }
            TaskActiveOrNewUserStatus tmp2 = tmp1.get(status);
            if (tmp2 == null) {
                continue;
            }
            tmp2.setAvgTime(e.getSumpasstime());  // 平均时间
            tmp2.setPlayTimes(e.getTimes());  // 总次数
        }

        Map<String, TaskActiveOrNewUserStatus> resultMap2 = new LinkedHashMap<>();
        // 整理数据
        for (Entry<String, Map<String, Map<String, TaskActiveOrNewUserStatus>>> entry : resultMap.entrySet()) {
            String dateStr = entry.getKey();
            Map<String, Map<String, TaskActiveOrNewUserStatus>> value = entry.getValue();
            for (Entry<String, Map<String, TaskActiveOrNewUserStatus>> entry1 : value.entrySet()) {
                String taskId = entry1.getKey();
                Map<String, TaskActiveOrNewUserStatus> value1 = entry1.getValue();

                //int okusernum = (okUserMap == null || TaskGameAction.taskOpenLevel.get(taskId) == null) ? 0 : okUserMap.get(TaskGameAction.taskOpenLevel.get(taskId));

                for (Entry<String, TaskActiveOrNewUserStatus> entry2 : sortMapByKey(value1).entrySet()) {
                    String taskStatus = entry2.getKey();
                    TaskActiveOrNewUserStatus v = entry2.getValue();

                    TaskActiveOrNewUserStatus t = resultMap2.get(dateStr + "-" + taskId);
                    if (t == null) {
                        t = new TaskActiveOrNewUserStatus();
                        t.setDateStr(dateStr);
                        t.setTaskId(v.getTaskId());
                        t.setTaskName(v.getTaskName());
                        t.setTaskType(v.getTaskType());
                        t.setOpenLevel(v.getOpenLevel());
                        // t.setOkUserNum(okusernum);

                        resultMap2.put(dateStr + "-" + taskId, t);
                    }
                    if (taskStatus.equals(TaskGameAction.task_join_status)) {  // 参与任务
                        t.setPlayUserNum(v.getPlayUserNum());
                        t.setPlayRadio(t.getOkUserNum() == 0 ? 0 : PageHelper.floatKeepTwoNumber(t.getPlayUserNum() * 1.0 / t.getOkUserNum()));
                        t.setPlayTimes(v.getPlayTimes());
                        t.setAvgPlayTimes(t.getPlayTimes() == 0 ? 0 : (int) Math.round(t.getPlayTimes() * 1.0 / t.getPlayUserNum()));
                        if (t.getPlayRadio() > 1) {
                            t.setPlayRadio(1);
                        }
                    } else if (taskStatus.equals(TaskGameAction.task_pass_status)) {  // 完成任务
                        t.setOkPlayTimes(v.getPlayTimes());
                        t.setOkRadio(t.getPlayTimes() == 0 ? 0 : PageHelper.floatKeepTwoNumber(t.getOkPlayTimes() * 1.0 / t.getPlayTimes()));
                        t.setAvgTime(t.getPlayTimes() == 0 ? 0 : PageHelper.floatKeepTwoNumber(v.getAvgTime() / 60.0 / t.getOkPlayTimes()));
                        if (t.getOkRadio() > 1) {
                            t.setOkRadio(1);
                        }
                    }
                }
            }
        }

        ArrayList<TaskGameManager.TaskActiveOrNewUserStatus> result = new ArrayList<>(resultMap2.values());
        Collections.sort(result, new TaskGameManager.TaskActiveOrNewUserStatus().comparatorDate);

        return result;
    }

    public List<TaskActiveOrLossUserStayRadio> getTaskActiveUserStayRadio(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer, List<Integer> queryTaskName, Map<String, Map<String, Integer>> levelNumTemp) {
        List<TaskActiveOrLossUserStayRadio> result = new ArrayList<>();

        // stay
        List<EntityActiveRoleTaskStay> datas = activeRoleTaskStayManager.getActiveRoleTaskStay(dateStart, dateEnd, queryPlatform, queryChannel, queryServer, queryTaskName);
        for (EntityActiveRoleTaskStay e : datas) {
            String dateStr = Time.getDateStr(e.getDay());
            String taskid = e.getTaskid() + "";
            TaskActiveOrLossUserStayRadio i = new TaskActiveOrLossUserStayRadio();
            i.setDateStr(dateStr);
            i.setTaskId(taskid);
            i.setTaskName(TaskGameAction.taskName.get(taskid) == null ? taskid : TaskGameAction.taskName.get(taskid)); // 任务名称
            i.setTaskType(TaskGameAction.taskType.get(taskid) == null ? taskid : TaskGameAction.taskType.get(taskid)); // 任务类型
            //i.setUserNum(okusernum);
            i.setStayUserNum(e.getRolenum());
            i.setStayRadio(i.getUserNum() == 0 ? 0 : PageHelper.floatKeepTwoNumber(i.getStayUserNum() * 1.0 / i.getUserNum()));

            result.add(i);
        }

        Collections.sort(result, new TaskActiveOrLossUserStayRadio().comparatorDate);

        return result;
    }

    public List<TaskActiveOrLossUserStayRadio> getTaskLossUserStayRadio(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer, List<Integer> queryTaskName, Map<String, Map<String, Integer>> levelNumTemp) {
        List<TaskActiveOrLossUserStayRadio> result = new ArrayList<>();

        // stay
        List<EntityNewRoleSecondLossTaskStay> datas = newRoleSecondLossTaskStayManager.getNewRoleSecondLossTaskStay(dateStart, dateEnd, queryPlatform, queryChannel, queryServer, queryTaskName);
        for (EntityNewRoleSecondLossTaskStay e : datas) {
            String dateStr = Time.getDateStr(e.getDay());
            String taskid = e.getTaskid() + "";
            TaskActiveOrLossUserStayRadio i = new TaskActiveOrLossUserStayRadio();
            i.setDateStr(dateStr);
            i.setTaskId(taskid);
            i.setTaskName(TaskGameAction.taskName.get(taskid) == null ? taskid : TaskGameAction.taskName.get(taskid)); // 任务名称
            i.setTaskType(TaskGameAction.taskType.get(taskid) == null ? taskid : TaskGameAction.taskType.get(taskid)); // 任务类型
            // i.setUserNum(okusernum);
            i.setStayUserNum(e.getRolenum());
            i.setStayRadio(i.getUserNum() == 0 ? 0 : PageHelper.floatKeepTwoNumber(i.getStayUserNum() * 1.0 / i.getUserNum()));

            result.add(i);
        }

        Collections.sort(result, new TaskActiveOrLossUserStayRadio().comparatorDate);

        return result;
    }

    private Map<String, TaskActiveOrNewUserStatus> sortMapByKey(Map<String, TaskActiveOrNewUserStatus> oriMap) {
        if (oriMap == null || oriMap.isEmpty()) {
            return null;
        }
        Map<String, TaskActiveOrNewUserStatus> sortedMap = new TreeMap<>(new Comparator<String>() {
            public int compare(String key1, String key2) {
                int intKey1 = 0, intKey2 = 0;
                try {
                    intKey1 = Integer.parseInt(key1);
                    intKey2 = Integer.parseInt(key2);
                } catch (Exception e) {
                    intKey1 = 0;
                    intKey2 = 0;
                }
                return intKey1 - intKey2;
            }});
        sortedMap.putAll(oriMap);
        return sortedMap;
    }

    /**
     * 符合条件的活跃或新增用户数
     * @param dateStart
     * @param dateEnd
     * @param queryPlatform
     * @param queryChannel
     * @param queryServer
     * @param isActive 是不是活跃用户，不是活跃用户就是新增用户
     * @return
     */
    public Map<String, Map<String, Integer>> getAllActiveOrNewUserByLevel(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer, boolean isActive) {
        // 求各个日期的满足条件的各个级别的用户数
        Map<String, Map<String, Integer>> levelNumTemp = new HashMap<>();  // dateStr={levelStr=num}
        Set<Integer> levels = new HashSet<>();
        int minLevel = 0;
        /*for (Entry<String, String> entry : TaskGameAction.taskOpenLevel.entrySet()) {
            if (!GameParamConfigManager.ALL_FLAT.equals(entry.getKey())) {
                int l = Integer.parseInt(entry.getValue());
                levels.add(l);
                if (minLevel > l) {
                    minLevel = l;
                }
            }
        }*/
        List<Object[]> levelList = isActive ? activeUser1LevelDistributeManager.getAllKindUserNumberGroupByLevel(dateStart, dateEnd, queryPlatform, queryChannel, queryServer, minLevel) : newUser1LevelDistributeManager.getAllKindUserNumberGroupByLevel(dateStart, dateEnd, queryPlatform, queryChannel, queryServer, minLevel);

        for(Object[] o : levelList) {
            String dateStr = o[0].toString();
            String levelStr = o[1].toString();
            int levelInt = Integer.parseInt(levelStr);
            int num = Integer.parseInt(o[2].toString());

            Map<String, Integer> levelTemp = levelNumTemp.get(dateStr);
            if (levelTemp == null) {
                levelTemp = new HashMap<>();
                levelNumTemp.put(dateStr, levelTemp);

                for (int i : levels) {
                    levelTemp.put(i + "", 0);
                }
            }
            for (Entry<String, Integer> entry : levelTemp.entrySet()) {
                if (Integer.parseInt(entry.getKey()) <= levelInt) {
                    levelTemp.put(entry.getKey(), entry.getValue() + num);
                }
            }
        }

        return levelNumTemp;
    }

    // 活跃用户和新增用户副本完成情况数据类
    public class TaskActiveOrNewUserStatus {
        private String dateStr; // 日期
        private String taskType; // 任务类型
        private String taskId; // 任务ID
        @ChartFlow(name="任务名称")
        private String taskName; // 任务名称
        private String taskStatus;  // 任务状态
        private int openLevel; // 开启等级
        private int okUserNum; // 满足条件角色数
        private int playUserNum; // 参与角色数
        private float playRadio; // 参与率
        private int playTimes; // 参与次数
        private int okPlayTimes; // 成功次数
        @ChartSelect(name = "成功率", key = 1)
        @ChartData1(name = "成功率", key = 1)
        private float okRadio; // 成功率
        private int avgPlayTimes; // 人均次数 playTimes / playUserNum
        private float avgTime; // 平均完成时间
        @ChartSelect(name = "转化率", key = 2)
        @ChartData1(name = "转化率", key = 2)
        private float tranRadio;

        // 根据日期排序的比较器
        public final Comparator<TaskActiveOrNewUserStatus> comparatorDate = new Comparator<TaskActiveOrNewUserStatus>() {
            public int compare(TaskActiveOrNewUserStatus s1, TaskActiveOrNewUserStatus s2) {
                return s2.getDateStr().compareTo(s1.getDateStr());
            }
        };

        public String getDateStr() {
            return dateStr;
        }

        public void setDateStr(String dateStr) {
            this.dateStr = dateStr;
        }

        public String getTaskType() {
            return taskType;
        }

        public void setTaskType(String taskType) {
            this.taskType = taskType;
        }

        public String getTaskId() {
            return taskId;
        }

        public void setTaskId(String taskId) {
            this.taskId = taskId;
        }

        public String getTaskName() {
            return taskName;
        }

        public void setTaskName(String taskName) {
            this.taskName = taskName;
        }

        public String getTaskStatus() {
            return taskStatus;
        }

        public void setTaskStatus(String taskStatus) {
            this.taskStatus = taskStatus;
        }

        public int getOpenLevel() {
            return openLevel;
        }

        public void setOpenLevel(int openLevel) {
            this.openLevel = openLevel;
        }

        public int getOkUserNum() {
            return okUserNum;
        }

        public void setOkUserNum(int okUserNum) {
            this.okUserNum = okUserNum;
        }

        public int getPlayUserNum() {
            return playUserNum;
        }

        public void setPlayUserNum(int playUserNum) {
            this.playUserNum = playUserNum;
        }

        public float getPlayRadio() {
            return playRadio;
        }

        public void setPlayRadio(float playRadio) {
            this.playRadio = playRadio;
        }

        public int getPlayTimes() {
            return playTimes;
        }

        public void setPlayTimes(int playTimes) {
            this.playTimes = playTimes;
        }

        public int getOkPlayTimes() {
            return okPlayTimes;
        }

        public void setOkPlayTimes(int okPlayTimes) {
            this.okPlayTimes = okPlayTimes;
        }

        public float getOkRadio() {
            return okRadio;
        }

        public void setOkRadio(float okRadio) {
            this.okRadio = okRadio;
        }

        public int getAvgPlayTimes() {
            return avgPlayTimes;
        }

        public void setAvgPlayTimes(int avgPlayTimes) {
            this.avgPlayTimes = avgPlayTimes;
        }

        public float getAvgTime() {
            return avgTime;
        }

        public void setAvgTime(float avgTime) {
            this.avgTime = avgTime;
        }

        public float getTranRadio() {
            return tranRadio;
        }

        public void setTranRadio(float tranRadio) {
            this.tranRadio = tranRadio;
        }
    }

    // 活跃用户停留率和新增次日流失停留率数据类
    public class TaskActiveOrLossUserStayRadio {
        private String dateStr; // 日期
        private String taskType; // 任务类型
        private String taskId; // 任务ID
        private String taskName; // 任务名称
        private int stayUserNum; // 停留角色数
        private int userNum; // 活跃或新增次日流失角色数
        private float stayRadio; // 停留率

        public String getDateStr() {
            return dateStr;
        }

        public void setDateStr(String dateStr) {
            this.dateStr = dateStr;
        }

        public String getTaskType() {
            return taskType;
        }

        public void setTaskType(String taskType) {
            this.taskType = taskType;
        }

        public String getTaskId() {
            return taskId;
        }

        public void setTaskId(String taskId) {
            this.taskId = taskId;
        }

        public String getTaskName() {
            return taskName;
        }

        public void setTaskName(String taskName) {
            this.taskName = taskName;
        }

        public int getStayUserNum() {
            return stayUserNum;
        }

        public void setStayUserNum(int stayUserNum) {
            this.stayUserNum = stayUserNum;
        }

        public int getUserNum() {
            return userNum;
        }

        public void setUserNum(int userNum) {
            this.userNum = userNum;
        }

        public float getStayRadio() {
            return stayRadio;
        }

        public void setStayRadio(float stayRadio) {
            this.stayRadio = stayRadio;
        }

        // 根据日期排序的比较器
        public final Comparator<TaskActiveOrLossUserStayRadio> comparatorDate = new Comparator<TaskActiveOrLossUserStayRadio>() {
            public int compare(TaskActiveOrLossUserStayRadio s1, TaskActiveOrLossUserStayRadio s2) {
                return s2.getDateStr().compareTo(s1.getDateStr());
            }
        };
    }
}
